package com.itheima.controller;

import com.itheima.pojo.Dept;
import com.itheima.service.DeptService;
import com.itheima.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class DeptController {

    @Autowired
    private DeptService deptService;

    //查询列表
    @GetMapping("/depts")
    public Result findAll(){
        List<Dept> list= deptService.findAll();
        return Result.success(list);
    }

   //保存
    @PostMapping("/depts")
    public Result Save(@RequestBody Dept dept){
        deptService.save(dept);
        return Result.success();
    }


    //删除部门
    @DeleteMapping("/depts/{id}")
    public Result deleteById(@PathVariable("id") Integer id){
        deptService.deleteById(id);
        return Result.success();
    }







}
